<template>
  <div>
    <FilterTable ref="table" :columns="columns" :fetchapi="fetchApi" :params="fetchParams" :datakey="'rows'" :isSelectColumn="false" :onColumnsChange="columns => (this.columns = columns)" />
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
import { getComplaintInfo, getRepairHistoryInfo } from '@/api/customerRepair/customerCareCTI';

export default {
  name: '',
  mixins: [dictionary],
  props: {
    phone: {
      type: String,
      default: ''
    }
  },
  
  data() {
    return {
      fetchApi: getComplaintInfo,
      // fetchParams: { phone:this.phone ,xhrAbort: false },
      fetchParams: this.phone ? { phone: this.phone } : { xhrAbort: true },
      columns: this.createColumns()
    };
  },
  methods: {
    createColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '投诉编号',
          dataIndex: 'COMPLAINT_NO',
          minWidth: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '投诉类型',
          dataIndex: 'COMPLAINT_TYPE',
          minWidth: 100,
          sorter: true,
          filter: true,
          render: props => {
            return <span>{this.createDictText(props.row.COMPLAINT_TYPE, '8007')}</span>;
          }
        },
        {
          title: '投诉来源',
          dataIndex: 'COMPLAINT_ORIGIN',
          minWidth: 100,
          sorter: true,
          filter: true,
          filterType: 'input',
          render: props => {
            return <span>{this.createDictText(props.row.COMPLAINT_ORIGIN, '8009')}</span>;
          }
        },
        {
          title: '投诉时间',
          dataIndex: 'COMPLAINT_DATE',
          minWidth: 120,
          sorter: true,
          filter: true,
          filterType: 'date-range',
          dateFormat: 'yyyy-MM-dd'
        },
        {
          title: '处理状态',
          dataIndex: 'HANDLE_STATUS',
          minWidth: 100,
          sorter: true,
          filter: true,
          render: props => {
            return <span>{this.createDictText(props.row.HANDLE_STATUS, '8048')}</span>;
          }
        },
        {
          title: '投诉人',
          dataIndex: 'COMPLAINT_NAME',
          minWidth: 100,
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '投诉人电话',
          dataIndex: 'COMPLAINT_PHONE',
          minWidth: 100,
          sorter: true,
          filter: true,
          filterType: 'input'
        }
      ];
    }
  }
};
</script>
